package com.sci.controller;

import com.sci.entity.Business;
import com.sci.service.BusinessService;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/business")
public class BusinessController {
    @Resource
    private BusinessService businessService;

    @GetMapping("/all")
    @Cacheable(value = "businessList", key = "'all'")
    public List<Business> findAllBusiness(){
        return businessService.findAllBusiness();
    }

    @GetMapping("/type/{type}")
    public List<Business> getByType(@PathVariable(value = "type") Integer type) {
        return businessService.getBusinessesByType(type);
    }

    @GetMapping("/search/{keyword}")
    public List<Business> searchBusiness(@PathVariable(value = "keyword") String keyword) {
        return businessService.searchBusiness(keyword);
    }

    @GetMapping("/id/{businessId}")
    public Business getBusinessById(@PathVariable(value = "businessId") String businessId) {
        return businessService.getBusinessById(businessId);
    }
}
